from selenium import webdriver
from selenium.webdriver.common.by import By
import time
driver = webdriver.Chrome()
driver.get('https://tieba.baidu.com/f?kw=%E8%8F%9C%E8%B0%B1&ie=utf-8&pn=0')

# print(driver.page_source)
while True:
    if driver.page_source.find('下一页&gt;') != -1:

        # driver.implicitly_wait(3)
        driver.find_element(By.CLASS_NAME,value='next').click()
        time.sleep(1)
    else:
        print('结束了')
        break